package org.jleaf.springcloud.account;

import org.jleaf.springcloud.account.entity.Account;
import org.jleaf.springcloud.account.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yaoshuhong
 * @date 2016-08-03 15:41
 */
@SpringBootApplication
@EnableDiscoveryClient
@RestController
public class AccountApplication {

    @Autowired
    private AccountService accountService;

    @RequestMapping("balance")
    public Double balance(String id) {
        Account account = accountService.findById(id);
        Assert.notNull(account, "用户不存在");
        return account.getBalance();
    }

    public static void main(String[] args) {
        SpringApplication.run(AccountApplication.class);
    }

}
